﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EcoSystem
{
    /// <summary>
    /// HTTP口调用请求提供给Script引擎的封装类
    /// </summary>
    public interface IApiScriptService
    {

        /// <summary>
        /// 发送POST请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="content"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<string> PostAsync(string url, string content, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发送POST请求
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="url"></param>
        /// <param name="content"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<TResult> PostAsync<TResult>(string url, string content, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发送PUT请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="content"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<string> PutAsync(string url, string content, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发送PUT请求
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="url"></param>
        /// <param name="content"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<TResult> PutAsync<TResult>(string url, string content, Dictionary<string, string> headers = null);


        /// <summary>
        /// 发送GET请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="queryString"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<string> GetAsync(string url, string queryString = null, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发送GET请求
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="url"></param>
        /// <param name="queryString"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<TResult> GetAsync<TResult>(string url, string queryString = null, Dictionary<string, string> headers = null);


        /// <summary>
        /// 发送DELETE请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="queryString"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<string> DeleteAsync(string url, string queryString = null, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发送DELETE请求
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="url"></param>
        /// <param name="queryString"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<TResult> DeleteAsync<TResult>(string url, string queryString = null, Dictionary<string, string> headers = null);
    }
}
